package com.first.mapper;

import com.first.entity.UserEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {

    @Insert("INSERT INTO user VALUES(NULL,#{userName},#{password},#{role},#{name},#{sex},#{address})")
    void registerUser(@Param("userName") String userName,@Param("password") String password,@Param("role") String role,@Param("name") String name,@Param("sex") String sex,@Param("address") String address);

    @Select("SELECT * FROM user WHERE username = #{userName} and password = #{password}")
    UserEntity loginUser(@Param("userName") String userName,@Param("password") String password);

    @Delete("DELETE FROM user WHERE id=#{id}")
    int cancelUser(Integer id);

    @Select("SELECT * FROM user")
    List <UserEntity> getUsersList();

}
